package com.zxcrm.web.controller.zxcrm;

import com.zxcrm.common.annotation.Log;
import com.zxcrm.common.core.controller.BaseController;
import com.zxcrm.common.core.domain.AjaxResult;
import com.zxcrm.common.core.page.TableDataInfo;
import com.zxcrm.common.enums.BusinessType;
import com.zxcrm.common.utils.poi.ExcelUtil;
import com.zxcrm.zxcrm.domain.ZxcrmBussinessProduct;
import com.zxcrm.zxcrm.service.IZxcrmBussinessProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 商机产品关系表Controller
 * 
 * @author xu
 * @date 2025-07-09
 */
@RestController
@RequestMapping("/zxcrm/bussinessProduct")
public class ZxcrmBussinessProductController extends BaseController
{
    @Autowired
    private IZxcrmBussinessProductService zxcrmBussinessProductService;

    /**
     * 查询商机产品关系表列表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:bussinessProduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxcrmBussinessProduct zxcrmBussinessProduct)
    {
        startPage();
        List<ZxcrmBussinessProduct> list = zxcrmBussinessProductService.selectZxcrmBussinessProductList(zxcrmBussinessProduct);
        return getDataTable(list);
    }

    /**
     * 导出商机产品关系表列表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:bussinessProduct:export')")
    @Log(title = "商机产品关系表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxcrmBussinessProduct zxcrmBussinessProduct)
    {
        List<ZxcrmBussinessProduct> list = zxcrmBussinessProductService.selectZxcrmBussinessProductList(zxcrmBussinessProduct);
        ExcelUtil<ZxcrmBussinessProduct> util = new ExcelUtil<ZxcrmBussinessProduct>(ZxcrmBussinessProduct.class);
        util.exportExcel(response, list, "商机产品关系表数据");
    }

    /**
     * 获取商机产品关系表详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:bussinessProduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zxcrmBussinessProductService.selectZxcrmBussinessProductById(id));
    }

    /**
     * 新增商机产品关系表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:bussinessProduct:add')")
    @Log(title = "商机产品关系表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxcrmBussinessProduct zxcrmBussinessProduct)
    {
        return toAjax(zxcrmBussinessProductService.insertZxcrmBussinessProduct(zxcrmBussinessProduct));
    }

    /**
     * 修改商机产品关系表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:bussinessProduct:edit')")
    @Log(title = "商机产品关系表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxcrmBussinessProduct zxcrmBussinessProduct)
    {
        return toAjax(zxcrmBussinessProductService.updateZxcrmBussinessProduct(zxcrmBussinessProduct));
    }

    /**
     * 删除商机产品关系表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:bussinessProduct:remove')")
    @Log(title = "商机产品关系表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zxcrmBussinessProductService.deleteZxcrmBussinessProductByIds(ids));
    }
}
